P in K
最も基本的な
Mapped Types
の形
{[P in K]: T}
K
は、
union型 (ts)
code:TypeScript
type T = {
key in 'x' | 'y'
: number }; // {x: number; y: number}